﻿Public Class mnuPrincipal


    Public Sub btnUsuarios_Click(sender As Object, e As EventArgs) Handles btnUsuarios.Click

        Me.Cursor = System.Windows.Forms.Cursors.WaitCursor

        'Remuevo user control anterior
        For Each uc As UserControl In SplitContainer1.Panel2.Controls
            SplitContainer1.Panel2.Controls.Remove(uc)
        Next

        'Cargo el user control
        varUcUsuarios = New ucUsuarios
        SplitContainer1.Panel2.Controls.Add(varUcUsuarios)
        varUcUsuarios.BringToFront()
        varUcUsuarios.Dock = DockStyle.Fill

        'Cargo la grilla
        sqlConsulta = "SELECT CONCAT(Nombre, ' ', Apellido) As Persona, Email, Telefono, r.Name As Rango, Activo"
        sqlConsulta = sqlConsulta & " FROM users u LEFT JOIN roles r ON u.rango = r.Id"
        cn.LlenarGrilla(varUcUsuarios.dgvUsuarios, sqlConsulta)

        Me.Cursor = System.Windows.Forms.Cursors.Default

    End Sub

    Private Sub btnTratadoras_Click(sender As Object, e As EventArgs) Handles btnTratadoras.Click

        Me.Cursor = System.Windows.Forms.Cursors.WaitCursor

        'Remuevo user control anterior
        For Each uc As UserControl In SplitContainer1.Panel2.Controls
            SplitContainer1.Panel2.Controls.Remove(uc)
        Next

        'Cargo el user control
        varUcTratadoras = New ucTratadoras
        SplitContainer1.Panel2.Controls.Add(varUcTratadoras)
        varUcTratadoras.BringToFront()
        varUcTratadoras.Dock = DockStyle.Fill

        'Cargo la grilla
        sqlConsulta = "SELECT Id, modelo as Nombre, Model As Modelo, Serie FROM tratadoras"
        'sqlConsulta = sqlConsulta & " FROM users u LEFT JOIN roles r ON u.rango = r.Id"
        cn.LlenarGrilla(varUcTratadoras.dgvTratadoras, sqlConsulta)

        Me.Cursor = System.Windows.Forms.Cursors.Default


    End Sub

    Private Sub mnuPrincipal_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        'SplitContainer1.Panel2.Controls.Add(varUcUsuarios)
        'varUcUsuarios.BringToFront()
        'varUcUsuarios.Dock = DockStyle.Fill
    End Sub

    Private Sub btnProcesamiento_Click(sender As Object, e As EventArgs) Handles btnProcesamiento.Click

    End Sub
End Class
